#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#define BUFFER_SIZE 5



/*数组*/
int main()
{

    int array1[BUFFER_SIZE];//数组定义
    //整个数组不允许使用魔数
    

    //int len = sizeof(array);

    //  printf("len:%d\n",len);

    //  char array2[10];
    //  int len1 = sizeof(array1);

    /*2.数组的值*/
    /*
    array1[0] = 10;
    array1[1]=20;
    array1[2] =30;
    array1[3] =40;
    array1[4] =50;
    */

    for(int idx = 0;idx <BUFFER_SIZE; idx++)
    {
        array1[idx] = (idx +1)*10;
    }


    /*连续的存储空间*/
   // printf("array1[0]:0x%x",array1[0]);//数组名
    
    for(int idx = 0; idx < BUFFER_SIZE;idx++)
    {
        printf("array1[%d] = %d\n",idx,array1[idx]);
    }


    /*3.连续的存储空间*/
    printf("0x%p\n",&array1[0]);
    printf("0x%p\n",&array1[1]);
    printf("0x%p\n",&array1[2]);
    printf("0x%p\n",&array1[3]);
    printf("0x%p\n",&array1[4]);



    /*4.脏数据*/
    int a;
    printf("a:%d\n",a);
    
    int array5[BUFFER_SIZE];
    memset (array5,0,sizeof(array5));///清除脏数据
    for(int idx = 0; idx < BUFFER_SIZE; idx++)
    {
        printf("array5[%d] = %d\n", idx, array5[idx]);
    }

    /* 5.数组的本质*/
    /* todo...*/
    /* 数组名就是数组的首地址。数组的第一个元素也是首地址*/

    printf("0x%p\n",array5);
    printf("0x%p\n",&array5[0]);

    /* 6.数组占的总字节大小*/
    int totallen = sizeof (array5);
    printf("tatollen:%d\n",totallen);
    int sololen = sizeof(array5[0]);
    printf("sololen:%d\n",sololen);

    int elementsize = totallen / sololen;
    printf("element size:%d\n",elementsize);




    return 0;

}